# coding: utf-8

import pandas as pd
from fuzzywuzzy import fuzz
from fuzzywuzzy import process


#读取数据
data=pd.read_excel("name_similarity.xlsx")
data.fillna("", inplace=True)

data["ratio"] = data.apply(lambda x: fuzz.ratio(x.yd_name, x.cub_name), axis=1)
data["partial_ratio"] = data.apply(lambda x: fuzz.partial_ratio(x.yd_name, x.cub_name), axis=1)
data["token_sort_ratio"] = data.apply(lambda x: fuzz.token_sort_ratio(x.yd_name, x.cub_name), axis=1)
data["token_set_ratio"] = data.apply(lambda x: fuzz.token_set_ratio(x.yd_name, x.cub_name), axis=1)
data.to_excel("name_similarity_mapping_all.xlsx",index=False)

# data.apply(lambda x: x.yd_name, axis=1)
# data.apply(lambda x: x.cub_name, axis=1)
# def f(x):
#     print(fuzz.ratio(x.yd_name, x.cub_name))
#     return fuzz.ratio(x.yd_name, x.cub_name)
# data.apply(f, axis=1)
# data.apply(lambda x: fuzz.ratio(x.yd_name, x.cub_name), axis=1)
# data.apply(lambda x: fuzz.partial_ratio(x.yd_name, x.cub_name), axis=1)
# data.apply(lambda x: fuzz.token_sort_ratio(x.yd_name, x.cub_name), axis=1)
# data.apply(lambda x: fuzz.token_set_ratio(x.yd_name, x.cub_name), axis=1)
